<template>
	<view>
		
		<view class="box">
			<text>
				已成功支付
			</text>
			<button @click="chage">{{num}}秒返回首页</button>
		</view>
		
	</view>
</template>

<script>
	
	import {
		orderpay
	
	} from "../../../api/movieService.js"
	import{baseurl} from '../../../api/request.js';
	export default {
		data() {
			return {
				num: 5,
				timer: null
			}
		},
		
		async onLoad(option) {
			
		
			let {
				id
			} = option;
			// let res = await orderpay(10)
			// console.log(res);
			
			this.onSetTimeout()
			
			
			
		},
		
		methods: {
			onSetTimeout() {
				this.timer = setInterval(() => {
					this.num--;
					if (this.num === 0) {
						this.clearTimer();
						uni.switchTab({
							url:'/pages/index/index'
						})
					}
				}, 1000);
			},
			clearTimer() {
				clearInterval(this.timer);
				this.timer = null;
			},
			chage(){
				clearInterval(this.timer);
				this.timer = null;
				uni.switchTab({
					url:'/pages/index/index'
				})
			}
		}
	}
</script>

<style lang="scss">

    .box {
    	width: 100vw;
    	height: 100vh;
    	text-align: center;
    	/* line-height: 100vh; */
    	font-size: 26px;
    	padding-top: 50%;
    }


</style>
